package com.example.lib_core.mvc;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment {

    private View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate( getLayoutId(), container, false);

        initView();
        setOperation();
        setLinstener();
        return view;
    }

    protected abstract int getLayoutId();

    protected abstract void initView();

    protected abstract void setOperation();

    protected abstract void setLinstener();

    protected <T extends View>T f( int id) {
        T t = view.findViewById( id);
        return t;
    }

    protected void startClass(Class c) {
        startActivity( new Intent( getActivity(), c));
    }

    protected void startClass(Intent intent) {
        startActivity( intent);
    }



}
